package demo.letcode;

/**
 * todo
 *
 * @author taqo
 * @date 2021/5/8
 */
public class ListNode {
    public int val;
    public ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public void print(){
        ListNode n = this.val == 0 ? this.next : this;
        while (n != null) {
            System.out.print(n.val+" ");
            n = n.next;
        }
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(0);
        int a[] = {1,2,3,4,5,6};
        ListNode temp = head;
        for (int i = 0; i < a.length; i++) {
            ListNode n = new ListNode(a[i]);
            temp.next = n;
            temp = n;
        }
        head.print();
    }
}
